<?php
namespace AuctionCore\CarDealer;


/**
*车商功能单元测试
*@author爱民
*/
class TakeManTest extends \PHPUnit_Framework_TestCase {

	public function testAdd(){
           $dealer_id = M('car_dealer')->max('dealer_id');
           $a = new TakeMan($dealer_id);
           $data = array();           
           $data['deal_id'] = $dealer_id;
           $data['real_name'] = '王成'.time();
           $data['sex'] = '1';
           $data['mobile'] = '15921306031';
           $data['idcard'] = '130481197908062879';
           $data['take_num'] = '1';
           $data['status'] = '2';

           try{
               $res = $a->add($data);
           }catch (\Exception $e){
               echo $e->getMessage();
               $res = false;
           }
           //dump($res,true,null,false);
		   $this->assertTrue($res?true:false);
	}

	public function testEdit(){
           $dealer_id = M('car_dealer')->max('dealer_id');
           $a = new TakeMan($dealer_id);
            $data = array();
            $data['man_id'] = M('take_car_man')->max('man_id');
            $data['deal_id'] = $dealer_id;
            $data['real_name'] = '王成'.time();
            $data['sex'] = '2';
            $data['mobile'] = '15921306127';
            $data['idcard'] = '130481790806287';
            $data['take_num'] = '2';
            $data['status'] = '1';

            try{
                $res = $a->edit($data);
            }catch (\Exception $e){
                echo $e->getMessage();
                $res = false;
            }
           //dump($res,true,null,false);
		   $this->assertTrue($res?true:false);
	}

	public function testDetail(){
           $dealer_id = M('car_dealer')->max('dealer_id');
           $a = new TakeMan($dealer_id);
           $man_id = M('take_car_man')->max('man_id');
           $res = $a->detail($man_id);
           dump($res,true,null,false);
		   $this->assertTrue($res?true:false);
	}

    public function testGetList(){
            $dealer_id = M('car_dealer')->max('dealer_id');
            $a = new TakeMan($dealer_id);
            $res = $a->get_list();
            //dump($res,true,null,false);
 		   $this->assertTrue($res?true:false);
 	}

    public function testDel(){
              $dealer_id = M('car_dealer')->max('dealer_id');
              $a = new TakeMan($dealer_id);
              $man_id = '1';//M('take_car_man')->max('man_id');;
              try{
                  $res = $a->del($man_id);
              }catch (\Exception $e){
                  echo $e->getMessage();
                  $res = false;
              }
              //dump($res,true,null,false);
   		      $this->assertTrue($res?true:false);
   	}





}

?>